In [1]:
import json
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import datetime

import seaborn
seaborn.set_theme()

pd.set_option('future.no_silent_downcasting', True)
In [2]:
with open('regions-m49.json') as f:
    regions = json.load(f)['regions']
    regions = {v: n for n, v in regions.items()}

with open('countries-m49.json') as f:
    countries = json.load(f)['countries']
    country_subregions = {c['name']: regions[c['subRegion']] for c in countries}
    country_regions = {c['name']: regions[c['region']] for c in countries}
In [3]:
country_mapping = {
    'Czech Republic': 'Czechia',
    'Iran': 'Iran (Islamic Republic of)',
    'Russia': 'Russian Federation',
    'South Korea': 'Republic of Korea',
    'Taiwan': 'China',  # UN is an abomination
    'Turkey': 'T\u00fcrkiye',
    'United Kingdom': 'United Kingdom of Great Britain and Northern Ireland',
    'United States': 'United States of America',
}

max_year = 2023
years = range(1954, max_year + 1)
max_date = pd.to_datetime(datetime.date(year = max_year + 1, month = 1, day = 1))

copyright_text = 'CC BY-SA 4.0 Andrey Upadyshev (image) and\nWikipedia, List of commercial nuclear reactors (data)'
copyright_font_size = 10

def format_years_ticks(ax):
    for label in ax.get_xticklabels():
        if label.get_text() in ('1957', '1979', '1986', '2011'):
            label.set_color('red')


def format_number_plants_ticks(ax, ymin, ymax):
    def fmt(val, pos):
        return int(abs(val))
    ax.yaxis.set_major_formatter(fmt)
    ax.set_ylim(-ymin, ymax)
In [4]:
orig_input_df = pd.read_csv('./reactors.csv').convert_dtypes()
for col in ('Begin building', 'Commercial operation', 'Closed'):
    orig_input_df[f'{col} date'] = pd.to_datetime(orig_input_df[col])
    orig_input_df[f'{col}'] = orig_input_df[f'{col} date'].dt.year
In [5]:
input_df = orig_input_df[orig_input_df['Begin building'].notna() & (orig_input_df['Begin building'] <= max_year)].reset_index(drop=True)
input_df.loc[input_df['Commercial operation'] > max_year, 'Commercial operation'] = None
input_df.loc[input_df['Closed'] > max_year, 'Closed'] = None

input_df['SubRegion'] = input_df['Country'].map(lambda x: country_subregions[country_mapping.get(x, x)])
input_df['Region'] = input_df['Country'].map(lambda x: country_regions[country_mapping.get(x, x)])
input_df['Operated closed'] = input_df['Closed'].where(input_df['Commercial operation'].notna(), None)
input_df['Construction time'] = (input_df['Commercial operation date'] - input_df['Begin building date']).dt.total_seconds() / (365.25 * 24 * 60 * 60)
input_df
Out[5]:
Country Plant name Unit No. Type Model Status Capacity (MW) Begin building Commercial operation Closed Begin building date Commercial operation date Closed date SubRegion Region Operated closed Construction time
0 Argentina Atucha 1 PHWR Siemens-KWU Operational 335.0 1968.0 1974.0 NaN 1968-06-01 1974-06-24 NaT Latin America and the Caribbean Americas NaN 6.061602
1 Argentina Atucha 2 PHWR Siemens-KWU Operational 692.0 1981.0 2014.0 NaN 1981-07-14 2014-06-27 NaT Latin America and the Caribbean Americas NaN 32.952772
2 Argentina Embalse 1 PHWR CANDU-6 Operational 600.0 1974.0 1984.0 NaN 1974-04-01 1984-01-20 NaT Latin America and the Caribbean Americas NaN 9.804244
3 Argentina CAREM 1 PWR CAREM25 Under construction 25.0 2014.0 NaN NaN 2014-02-08 NaT NaT Latin America and the Caribbean Americas NaN NaN
4 Armenia Metsamor 1 PWR VVER-440/V-270 Shut down 376.0 1969.0 1977.0 1989.0 1969-07-01 1977-10-06 1989-02-25 Western Asia Asia 1989.0 8.265572
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
746 United States Watts Bar 2 PWR WH 4-Loop (ICECOND) Operational 1164.0 1973.0 2016.0 NaN 1973-09-01 2016-06-04 NaT Northern America Americas NaN 42.757016
747 United States Wolf Creek 1 PWR WH 4-Loop (DRY) Operational 1200.0 1977.0 1985.0 NaN 1977-05-31 1985-09-03 NaT Northern America Americas NaN 8.260096
748 United States Yankee Rowe 1 PWR WH (DRY) Dismantled 167.0 1957.0 1961.0 1991.0 1957-11-01 1961-07-01 1991-10-01 Northern America Americas 1991.0 3.663244
749 United States Zion 1 PWR WH (DRY) Dismantled 1040.0 1968.0 1973.0 1998.0 1968-12-01 1973-12-31 1998-02-13 Northern America Americas 1998.0 5.081451
750 United States Zion 2 PWR WH (DRY) Dismantled 1040.0 1968.0 1974.0 1998.0 1968-12-01 1974-09-17 1998-02-13 Northern America Americas 1998.0 5.793292

751 rows × 17 columns

In [6]:
total_constructed_by_subregion = input_df.groupby(['SubRegion', 'Region'])[['Begin building', 'Commercial operation', 'Closed']].count().reset_index().sort_values('Begin building', ascending=False).reset_index(drop=True)
total_constructed_by_subregion
Out[6]:
SubRegion Region Begin building Commercial operation Closed
0 Eastern Asia Asia 181 147 34
1 Northern America Americas 165 159 52
2 Western Europe Europe 125 120 58
3 Eastern Europe Europe 122 94 29
4 Northern Europe Europe 67 64 45
5 Southern Asia Asia 42 31 2
6 Southern Europe Europe 21 15 13
7 Latin America and the Caribbean Americas 11 7 2
8 Western Asia Asia 10 5 1
9 Northern Africa Africa 3 0 0
10 Sub-Saharan Africa Africa 2 2 0
11 Central Asia Asia 1 1 1
12 South-eastern Asia Asia 1 0 1
In [7]:
total_constructed_by_country = input_df.groupby(['Country', 'SubRegion', 'Region'])[['Begin building', 'Commercial operation', 'Closed']].count().reset_index().sort_values('Begin building', ascending=False).reset_index(drop=True)
total_constructed_by_country
Out[7]:
Country SubRegion Region Begin building Commercial operation Closed
0 United States Northern America Americas 140 134 46
1 China Eastern Asia Asia 81 55 0
2 France Western Europe Europe 69 68 12
3 Japan Eastern Asia Asia 62 59 26
4 Russia Eastern Europe Europe 62 47 10
5 United Kingdom Northern Europe Europe 46 44 35
6 Germany Western Europe Europe 39 36 39
7 India Southern Asia Asia 31 23 1
8 South Korea Eastern Asia Asia 30 27 2
9 Canada Northern America Americas 25 25 6
10 Ukraine Eastern Europe Europe 25 19 8
11 Sweden Northern Europe Europe 14 13 8
12 Spain Southern Europe Europe 14 10 7
13 Slovakia Eastern Europe Europe 9 8 3
14 Belgium Western Europe Europe 8 8 3
15 Bulgaria Eastern Europe Europe 8 6 4
16 Taiwan Eastern Asia Asia 8 6 6
17 Pakistan Southern Asia Asia 7 7 1
18 Italy Southern Europe Europe 6 4 6
19 Switzerland Western Europe Europe 6 6 2
20 Czech Republic Eastern Europe Europe 6 6 0
21 Finland Northern Europe Europe 5 5 0
22 Turkey Western Asia Asia 4 0 0
23 United Arab Emirates Western Asia Asia 4 3 0
24 Argentina Latin America and the Caribbean Americas 4 3 0
25 Belarus Eastern Europe Europe 4 2 2
26 Hungary Eastern Europe Europe 4 4 0
27 Brazil Latin America and the Caribbean Americas 3 2 0
28 Egypt Northern Africa Africa 3 0 0
29 Netherlands Western Europe Europe 2 2 1
30 Armenia Western Asia Asia 2 2 1
31 Bangladesh Southern Asia Asia 2 0 0
32 Cuba Latin America and the Caribbean Americas 2 0 2
33 Iran Southern Asia Asia 2 1 0
34 South Africa Sub-Saharan Africa Africa 2 2 0
35 Lithuania Northern Europe Europe 2 2 2
36 Mexico Latin America and the Caribbean Americas 2 2 0
37 Romania Eastern Europe Europe 2 2 0
38 Poland Eastern Europe Europe 2 0 2
39 Philippines South-eastern Asia Asia 1 0 1
40 Slovenia Southern Europe Europe 1 1 0
41 Austria Western Europe Europe 1 0 1
42 Kazakhstan Central Asia Asia 1 1 1

Construction time¶

In [8]:
construction_time = input_df.groupby(['Begin building'])['Construction time'].agg(['min', 'median', 'max']).reindex(years, fill_value=0)

fig, ax = plt.subplots(figsize=(11, 5))

construction_time.plot.bar(ax=ax, width=0.8)

ax.set_title('Years of construction time by the year when construction started - World')
ax.set_xlabel(None)
format_years_ticks(ax)
ax.yaxis.set_major_formatter(lambda val, pos: int(val))
ax.yaxis.set_major_locator(ticker.MultipleLocator(5))
ax.text(0, ax.get_ylim()[1] - 0.1, copyright_text, fontsize=copyright_font_size, verticalalignment='top')
ax.legend()

fig.tight_layout()
No description has been provided for this image
In [9]:
top_countries = total_constructed_by_country['Country'].to_list()
construction_time = input_df.groupby(['Country', 'Begin building'])['Construction time'].agg(['min', 'median', 'max'])
ymax = construction_time.max(axis=None) + 1

for c in top_countries:
    df = construction_time[construction_time.index.get_level_values(0) == c].droplevel(0).reindex(years, fill_value=0)
    
    fig, ax = plt.subplots(figsize=(11, 5))

    df.plot.bar(ax=ax, width=0.8)

    ax.set_title(f'Years of construction time by the year when construction started - {c}')
    ax.set_xlabel(None)
    format_years_ticks(ax)

    ax.yaxis.set_major_formatter(lambda val, pos: int(abs(val)))
    ax.yaxis.set_major_locator(ticker.MultipleLocator(5))

    ax.set_ylim(0, ymax)
    ax.text(0, ax.get_ylim()[1], copyright_text, fontsize=copyright_font_size, verticalalignment='top')
    ax.legend()

    fig.tight_layout()
/var/folders/2z/kr9wj6s90nn6nkdsddywzyfw0000gn/T/ipykernel_34796/1224979684.py:8: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.
  fig, ax = plt.subplots(figsize=(11, 5))
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Number of constructed and operated reactors¶

World stats¶

In [10]:
num_building_started = input_df.groupby(['Begin building'])['Begin building'].count()
num_connected = input_df.groupby(['Commercial operation'])['Commercial operation'].count()
num_closed = input_df.groupby(['Closed'])['Closed'].count()
num_operated_closed = input_df.groupby(['Operated closed'])['Operated closed'].count()

max_building_started = num_building_started.max()
max_num_closed = num_closed.max()
ymax = (max_building_started + 4) // 5 * 5
ymin = (max_num_closed + 4) // 5 * 5

combined = pd.concat([
        num_building_started,
        num_connected,
        num_closed,
        num_operated_closed,
    ], axis=1)

combined = combined.reindex(years, fill_value=0)

combined['Commercial operation tot'] = combined['Commercial operation'].fillna(0).cumsum()
combined['Operated closed tot'] = combined['Operated closed'].fillna(0).cumsum()
combined['In operation'] = combined['Commercial operation tot'] - combined['Operated closed tot']

fig, ax = plt.subplots(2, 1, figsize=(11, 10))

ax1, ax2 = ax

combined['Begin building'].plot.bar(ax=ax1, label='Construction started')
(-combined['Closed']).plot.bar(ax=ax1, color='red', label='Closed')

ax1.set_title('World')
ax1.set_xlabel(None)
format_years_ticks(ax1)
format_number_plants_ticks(ax1, ymin, ymax)
ax1.text(0, -ymin, copyright_text, fontsize=copyright_font_size, verticalalignment='bottom')
ax1.legend()

combined['In operation'].plot.bar(ax=ax2, label='Number in operation')
combined['Commercial operation'].plot.bar(ax=ax2, color='black', label='Operation started')
format_years_ticks(ax2)
#ax2.text(0, ax2.get_ylim()[1], copyright_text, fontsize=copyright_font_size, verticalalignment='top')
ax2.legend()

fig.tight_layout()
No description has been provided for this image

Region stats¶

In [11]:
total_constructed_by_region = input_df.groupby(['Region'])[['Begin building', 'Commercial operation', 'Closed']].count().reset_index().sort_values('Begin building', ascending=False).reset_index(drop=True)

num_building_started = input_df.groupby(['Region', 'Begin building'])['Begin building'].count()
num_connected = input_df.groupby(['Region', 'Commercial operation'])['Commercial operation'].count()
num_closed = input_df.groupby(['Region', 'Closed'])['Closed'].count()
num_operated_closed = input_df.groupby(['Region', 'Operated closed'])['Operated closed'].count()

#top_regions = total_constructed_by_region[total_constructed_by_region['Begin building'] > 10]['Region'].to_list()
top_regions = total_constructed_by_region['Region'].to_list()

regions = sorted(c for c in input_df['Region'].unique() if c in num_building_started)

max_building_started = num_building_started.max()
max_num_closed = num_closed.max()
ymax = (max_building_started + 4) // 5 * 5
ymin = (max_num_closed + 4) // 5 * 5
tot_ymax_regions = 250  # TODO: calculate from data


for c in top_regions:
    combined = pd.concat([
        num_building_started[c],
        num_connected[c] if c in num_connected else pd.DataFrame(columns=['Commercial operation']),
        num_closed[c] if c in num_closed else pd.DataFrame(columns=['Closed']),
        num_operated_closed[c] if c in num_operated_closed else pd.DataFrame(columns=['Operated closed']),
    ], axis=1)
    
    combined = combined.reindex(years, fill_value=0)

    combined['Commercial operation tot'] = combined['Commercial operation'].fillna(0).cumsum()
    combined['Operated closed tot'] = combined['Operated closed'].fillna(0).cumsum()
    combined['In operation'] = combined['Commercial operation tot'] - combined['Operated closed tot']

    fig, ax = plt.subplots(2, 1, figsize=(11, 10))

    ax1, ax2 = ax

    combined['Begin building'].plot.bar(ax=ax1, label='Construction started')
    (-combined['Closed']).plot.bar(ax=ax1, color='red', label='Closed')

    ax1.set_title(f'{c} (UN M49)')
    ax1.set_xlabel(None)
    format_years_ticks(ax1)
    format_number_plants_ticks(ax1, ymin, ymax)
    ax1.text(0, -ymin, copyright_text, fontsize=copyright_font_size, verticalalignment='bottom')
    ax1.legend()

    combined['In operation'].plot.bar(ax=ax2, label='Number in operation')
    combined['Commercial operation'].plot.bar(ax=ax2, color='black', label='Operation started')
    format_years_ticks(ax2)
    ax2.set_ylim(0, tot_ymax_regions)
    #ax2.text(0, ax2.get_ylim()[1], copyright_text, fontsize=copyright_font_size, verticalalignment='top')
    ax2.legend()


    fig.tight_layout()
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [12]:
europe_df = input_df[(input_df['Region'] == 'Europe') & (input_df['SubRegion'] != 'Eastern Europe') & (input_df['SubRegion'] != 'Lithuania')]
num_building_started = europe_df.groupby(['Begin building'])['Begin building'].count()
num_connected = europe_df.groupby(['Commercial operation'])['Commercial operation'].count()
num_closed = europe_df.groupby(['Closed'])['Closed'].count()
num_operated_closed = europe_df.groupby(['Operated closed'])['Operated closed'].count()

max_building_started = num_building_started.max()
max_num_closed = num_closed.max()
ymax = (max_building_started + 4) // 5 * 5
ymin = (max_num_closed + 4) // 5 * 5

combined = pd.concat([
        num_building_started,
        num_connected,
        num_closed,
        num_operated_closed,
    ], axis=1)

combined = combined.reindex(years, fill_value=0)

combined['Commercial operation tot'] = combined['Commercial operation'].fillna(0).cumsum()
combined['Operated closed tot'] = combined['Operated closed'].fillna(0).cumsum()
combined['In operation'] = combined['Commercial operation tot'] - combined['Operated closed tot']

fig, ax = plt.subplots(2, 1, figsize=(11, 10))

ax1, ax2 = ax

combined['Begin building'].plot.bar(ax=ax1, label='Construction started')
(-combined['Closed']).plot.bar(ax=ax1, color='red', label='Closed')

ax1.set_title('Europe excluding Eastern Europe and ex-USSR countries')
ax1.set_xlabel(None)
format_years_ticks(ax1)
format_number_plants_ticks(ax1, ymin, ymax)
ax1.text(0, -ymin, copyright_text, fontsize=copyright_font_size, verticalalignment='bottom')
ax1.legend()

combined['In operation'].plot.bar(ax=ax2, label='Number in operation')
combined['Commercial operation'].plot.bar(ax=ax2, color='black', label='Operation started')
format_years_ticks(ax2)
ax2.set_ylim(0, tot_ymax_regions)
#ax2.text(0, ax2.get_ylim()[1], copyright_text, fontsize=copyright_font_size, verticalalignment='top')
ax2.legend()

fig.tight_layout()
No description has been provided for this image

Subregion stats¶

In [13]:
num_building_started = input_df.groupby(['SubRegion', 'Begin building'])['Begin building'].count()
num_connected = input_df.groupby(['SubRegion', 'Commercial operation'])['Commercial operation'].count()
num_closed = input_df.groupby(['SubRegion', 'Closed'])['Closed'].count()
num_operated_closed = input_df.groupby(['SubRegion', 'Operated closed'])['Operated closed'].count()

sub_regions = sorted(c for c in input_df['SubRegion'].unique() if c in num_building_started)
#top_regions = total_constructed_by_subregion[total_constructed_by_subregion['Begin building'] > 10]['SubRegion'].to_list()
top_regions = total_constructed_by_subregion['SubRegion'].to_list()

max_building_started = num_building_started.max()
max_num_closed = num_closed.max()
ymax = (max_building_started + 4) // 5 * 5
ymin = (max_num_closed + 4) // 5 * 5


for c in top_regions:
    combined = pd.concat([
        num_building_started[c],
        num_connected[c] if c in num_connected else pd.DataFrame(columns=['Commercial operation']),
        num_closed[c] if c in num_closed else pd.DataFrame(columns=['Closed']),
        num_operated_closed[c] if c in num_operated_closed else pd.DataFrame(columns=['Operated closed']),
    ], axis=1)
    
    combined = combined.reindex(years, fill_value=0)

    combined['Commercial operation tot'] = combined['Commercial operation'].fillna(0).cumsum()
    combined['Operated closed tot'] = combined['Operated closed'].fillna(0).cumsum()
    combined['In operation'] = combined['Commercial operation tot'] - combined['Operated closed tot']

    fig, ax = plt.subplots(2, 1, figsize=(11, 10))

    ax1, ax2 = ax

    combined['Begin building'].plot.bar(ax=ax1, label='Construction started')
    (-combined['Closed']).plot.bar(ax=ax1, color='red', label='Closed')

    ax1.set_title(f'{c} (UN M49)')
    ax1.set_xlabel(None)
    format_years_ticks(ax1)
    format_number_plants_ticks(ax1, ymin, ymax)
    ax1.text(0, -ymin, copyright_text, fontsize=copyright_font_size, verticalalignment='bottom')
    ax1.legend()

    combined['In operation'].plot.bar(ax=ax2, label='Number in operation')
    combined['Commercial operation'].plot.bar(ax=ax2, color='black', label='Operation started')
    format_years_ticks(ax2)
    ax2.set_ylim(0, tot_ymax_regions)
    #ax2.text(0, ax2.get_ylim()[1], copyright_text, fontsize=copyright_font_size, verticalalignment='top')
    ax2.legend()


    fig.tight_layout()
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Country stats¶

In [14]:
num_building_started = input_df.groupby(['Country', 'Begin building'])['Begin building'].count()
num_connected = input_df.groupby(['Country', 'Commercial operation'])['Commercial operation'].count()
num_closed = input_df.groupby(['Country', 'Closed'])['Closed'].count()
num_operated_closed = input_df.groupby(['Country', 'Operated closed'])['Operated closed'].count()

countries = sorted(c for c in input_df['Country'].unique() if c in num_building_started)
#top_countries = total_constructed_by_country[total_constructed_by_country['Begin building'] >= 10]['Country'].to_list()
top_countries = total_constructed_by_country['Country'].to_list()

max_building_started = num_building_started.max()
max_num_closed = num_closed.max()
ymax = (max_building_started + 4) // 5 * 5
ymin = (max_num_closed + 4) // 5 * 5
tot_ymax = 120  # TODO: calculate from data


for c in top_countries:
    combined = pd.concat([
        num_building_started[c],
        num_connected[c] if c in num_connected else pd.DataFrame(columns=['Commercial operation']),
        num_closed[c] if c in num_closed else pd.DataFrame(columns=['Closed']),
        num_operated_closed[c] if c in num_operated_closed else pd.DataFrame(columns=['Operated closed']),
    ], axis=1)
    
    combined = combined.reindex(years, fill_value=0)

    combined['Commercial operation tot'] = combined['Commercial operation'].fillna(0).cumsum()
    combined['Operated closed tot'] = combined['Operated closed'].fillna(0).cumsum()
    combined['In operation'] = combined['Commercial operation tot'] - combined['Operated closed tot']

    fig, ax = plt.subplots(2, 1, figsize=(11, 10))

    ax1, ax2 = ax

    combined['Begin building'].plot.bar(ax=ax1, label='Construction started')
    (-combined['Closed']).plot.bar(ax=ax1, color='red', label='Closed')

    ax1.set_title(c)
    ax1.set_xlabel(None)
    format_years_ticks(ax1)
    format_number_plants_ticks(ax1, ymin, ymax)
    ax1.text(0, -ymin, copyright_text, fontsize=copyright_font_size, verticalalignment='bottom')
    ax1.legend()

    combined['In operation'].plot.bar(ax=ax2, label='Number in operation')
    combined['Commercial operation'].plot.bar(ax=ax2, color='black', label='Operation started')
    format_years_ticks(ax2)
    ax2.set_ylim(0, tot_ymax)
    #ax2.text(0, ax2.get_ylim()[1], copyright_text, fontsize=copyright_font_size, verticalalignment='top')
    ax2.legend()

    fig.tight_layout()
/var/folders/2z/kr9wj6s90nn6nkdsddywzyfw0000gn/T/ipykernel_34796/3530068090.py:31: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.
  fig, ax = plt.subplots(2, 1, figsize=(11, 10))
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Never opened reactors¶

In [15]:
# Never opened
never_opened_df = input_df[input_df['Commercial operation'].isna() & input_df['Begin building'].notna() & input_df['Closed'].notna()].sort_values('Closed')

num_building_started = never_opened_df.groupby(['Begin building'])['Begin building'].count()
num_closed = never_opened_df.groupby(['Closed'])['Closed'].count()

combined = pd.concat([
        num_building_started,
        num_closed,
    ], axis=1)

combined = combined.reindex(years, fill_value=0)

fig, ax = plt.subplots(figsize=(11, 5))

combined['Begin building'].plot.bar(ax=ax, label='Construction started')
(-combined['Closed']).plot.bar(ax=ax, color='red', label='Closed')

ax.set_title('Never operated reactors')
ax.set_xlabel(None)
format_years_ticks(ax)
ax.yaxis.set_major_formatter(lambda val, pos: int(val))
ax.text(0, ax.get_ylim()[0], copyright_text, fontsize=copyright_font_size, verticalalignment='bottom')
ax.legend()

fig.tight_layout()
No description has been provided for this image
In [16]:
never_opened_df.groupby(['Country', 'Closed'])['Closed'].count().sort_values(ascending=False)
Out[16]:
Country        Closed
Spain          1984.0    4
United States  1984.0    3
Belarus        1987.0    2
Cuba           1992.0    2
Germany        1990.0    2
Italy          1988.0    2
Poland         1990.0    2
Taiwan         2014.0    2
Ukraine        1987.0    2
               1990.0    2
United States  1983.0    2
Austria        1978.0    1
Germany        1985.0    1
Philippines    1986.0    1
Sweden         1970.0    1
Name: Closed, dtype: int64
In [17]:
never_opened_df.groupby(['Country', 'Begin building'])['Begin building'].count().sort_values(ascending=False)
Out[17]:
Country        Begin building
United States  1975.0            4
Poland         1982.0            2
Ukraine        1988.0            2
               1984.0            2
Germany        1983.0            2
Italy          1982.0            2
Taiwan         1999.0            2
Belarus        1983.0            2
Spain          1972.0            2
               1975.0            2
Sweden         1965.0            1
Austria        1972.0            1
Philippines    1976.0            1
Germany        1972.0            1
Cuba           1985.0            1
               1983.0            1
United States  1977.0            1
Name: Begin building, dtype: int64